﻿Module Module1

    Function createbat()
        Dim mcgetpas As String = "mc_" & Form1.pas
        Settings.LoadFromXmlFile()
        Dim textFile As String = Application.StartupPath & "\target\" & mcgetpas & "\bootbatbase.txt"
        If System.IO.File.Exists(textFile) Then
        Else
            createbootbase()
        End If
        '文字コード(ここでは、Shift JIS)
        Dim enc As System.Text.Encoding = System.Text.Encoding.GetEncoding("shift_jis")
        '行ごとの配列として、テキストファイルの中身をすべて読み込む
        Dim str As String = System.IO.File.ReadAllText(textFile, enc)
        Dim r1 As String = str.ToString.Replace("|appfold|", Application.StartupPath)
        Dim r2 As String = r1.Replace("|.mcfold|", Application.StartupPath & "\target\" & mcgetpas)
        Dim r3 As String = r2.Replace("|javap|", Settings.Instance.java)
        Dim r4 As String = r3.Replace("|msmem|", Settings.Instance.xms)
        Dim r5 As String = r4.Replace("|xcmem|", Settings.Instance.xmx)
        Dim r6 As String = r5.Replace("|mcID|", Settings.Instance.mcid)
        Dim r7 As String = r6.Replace("|mcpas|", Settings.Instance.mcpas)
        Dim bat As String = Application.StartupPath & "\boot.bat"
        Dim enc1 As System.Text.Encoding = System.Text.Encoding.GetEncoding("shift_jis")
        System.IO.File.AppendAllText(bat, r7, enc)
        Return ("a")
    End Function
    Function createbootbase()
        Dim a As String = Application.StartupPath & "\bootbatbase.txt"
        Dim b As String = Application.StartupPath & "\target\" & Form1.pas & "\bootbatbase.txt"
        My.Computer.FileSystem.CopyFile(a, b, _
        FileIO.UIOption.AllDialogs, FileIO.UICancelOption.DoNothing)
        Return ("b")
    End Function
    Function backup()
        Dim recurse As Boolean = True
        Dim fastZip As New ICSharpCode.SharpZipLib.Zip.FastZip()
        fastZip.CreateEmptyDirectories = True
        fastZip.UseZip64 = ICSharpCode.SharpZipLib.Zip.UseZip64.Dynamic
        fastZip.CreateZip(Form1.bfdir & "\" & Form1.file, Form1.bdir, recurse, Nothing, Nothing)
        Return ("c")
    End Function
    Function ftbimport()

        Return ("d")
    End Function

End Module
